package com.ssy.lingxi.after.sale.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 维修外部状态枚举
 * @author 伍将
 * @date 2020/9/1
 * @version 2.0.0
 */
public enum RepairGoodsOuterStatusEnum {

    /**
     * 所有
     */
    ALL(0, "所有状态"),
    /**
     * 待提交申请单-1
     */
    TO_BE_SUBMIT(1, "待提交申请单"),
    /**
     * 待确认申请单-2
     */
    TO_BE_CONFIRM(2, "待确认申请单"),
    /**
     * 不接受申请-3
     */
    UN_ACCEPT_APPLY(3, "不接受申请"),
    /**
     * 接受申请（待确认售后完成）-4
     */
    ACCEPT_APPLY(4, "待确认售后完成"),
    /**
     * 售后完成-5
     */
    COMPLETE(5, "售后完成");

    private final Integer code;
    private final String message;

    RepairGoodsOuterStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(RepairGoodsOuterStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getMessage();
    }

    public static RepairGoodsOuterStatusEnum getEnum(Integer code) {
        return Arrays.stream(RepairGoodsOuterStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL);
    }
}
